Question on libpq parameters

Поиск
Список
Период
Сортировка
От Owen Hartnett
Тема Question on libpq parameters
Дата
Msg-id p06240806c557c8691240@[192.168.0.107]
обсуждение исходный текст
Ответ на Re: Install question on Mac Leopard Server 10.5  (Shane Ambler <pgsql@Sheeky.Biz>)
Ответы Re: Question on libpq parameters  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
The following libpq code chokes on me with invalid input to an
integer parameter (state == PGRES_FATAL_ERR aPtr == "Error: Invalid
Input syntax for integer """ .   It fails on the call to
PQexecPrepared.  I suspect I'm not doing the parameters right.  Can
anyone spot anything wrong?

Thanks,

-Owen

char * getPicture(PGconn * myconnection, char * maplot, int unitno, int bldgno)
{
    PGresult * resultant;
    Oid paramTypes[3] = { 25, 23, 23 };
    ExecStatusType state;

    char * sqlquery = "Select image from images where maplot = $1
and unitno = $2 and imageno = $3";

    const char * myparamValues[3];
    char *    aPtr;

    myparamValues[0] = maplot;
    myparamValues[1] = &unitno;
    myparamValues[2] = &bldgno;


    resultant = PQprepare(myconnection, "pictureplan", sqlquery ,
3, paramTypes);
    if (PQresultStatus(resultant) == PGRES_COMMAND_OK)
    {
        resultant = PQexecPrepared(    myconnection,
"pictureplan", 3, myparamValues, NULL, NULL, 1);
        if (PQresultStatus(resultant) == PGRES_TUPLES_OK)
        {
            aPtr = PQgetvalue(resultant, 0, 0);
            return aPtr;
        }
        else
        {
            state = PQresultStatus(resultant);
            aPtr = PQresultErrorMessage(resultant);
        }
    }
    else
    {
        state = PQresultStatus(resultant);
        aPtr = PQresultErrorMessage(resultant);
    }
    return NULL;
}


В списке pgsql-general по дате отправления:

Предыдущее
От: Shane Ambler
Дата:
Сообщение: Re: Install question on Mac Leopard Server 10.5
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Question on libpq parameters